'=======================================
' 执行所有测试 case
'=======================================
Private Sub test_ALL_Case()
    ' copyToNewArray 测试
    test_copyToNewArray
End Sub

'--------------------------------------------------------
' copyToNewArray 测试
'--------------------------------------------------------
Private Sub test_copyToNewArray()
    Dim tempRef As IObjArrayRef
    Dim baseRef As IObjArrayRef
    Set baseRef = UtilsArrayRef.createRealObjArrayRef

    Dim c0 As Collection
    Set c0 = New Collection
    Dim c1 As Collection
    Set c1 = New Collection
    Dim c2 As Collection
    Set c2 = New Collection
    Dim c3 As Collection
    Set c3 = New Collection
    Dim c4 As Collection
    Set c4 = New Collection
    Dim c5 As Collection
    Set c5 = New Collection
    Dim c6 As Collection
    Set c6 = New Collection

    baseRef.Add c0
    baseRef.Add c1
    baseRef.Add c2
    baseRef.Add c3
    baseRef.Add c4
    baseRef.Add c5
    baseRef.Add c6

    Dim tempSlice As ObjArrayRefSlice
    Dim baseSlice As IObjArrayRef

    ' ------------------- 1. 空拷贝---------------------
    Set tempSlice = New ObjArrayRefSlice
    tempSlice.Init baseRef, 1, 1, 2
    Set baseSlice = tempSlice

    Set tempRef = baseSlice.copyToNewArray
    Debug.Assert tempRef.Count = 0

    Set tempRef = baseSlice.copyToNewArray(1)
    Debug.Assert tempRef.Count = 0

    Set tempRef = baseSlice.copyToNewArray(endIdx := 2)
    Debug.Assert tempRef.Count = 0

    ' ------------------- 2. 边界测试---------------------
    Set tempSlice = New ObjArrayRefSlice
    tempSlice.Init baseRef, 0, 10, 2
    Set baseSlice = tempSlice

    ' 1. 全部拷贝
    Set tempRef = baseSlice.copyToNewArray
    Debug.Assert tempRef.Count = 4
    Debug.Assert tempRef.Item(0) Is c0
    Debug.Assert tempRef.Item(1) Is c2
    Debug.Assert tempRef.Item(2) Is c4
    Debug.Assert tempRef.Item(3) Is c6

    ' 2. 结束索引边界
    Set tempRef = baseSlice.copyToNewArray(endIdx := 3)
    Debug.Assert tempRef.Count = 3
    Debug.Assert tempRef.Item(0) Is c0
    Debug.Assert tempRef.Item(1) Is c2
    Debug.Assert tempRef.Item(2) Is c4

    Set tempRef = baseSlice.copyToNewArray(endIdx := 4)
    Debug.Assert tempRef.Count = 4
    Debug.Assert tempRef.Item(0) Is c0
    Debug.Assert tempRef.Item(1) Is c2
    Debug.Assert tempRef.Item(2) Is c4
    Debug.Assert tempRef.Item(3) Is c6

    ' 3. 起始 == 结束
    Set tempRef = baseSlice.copyToNewArray(1, 1)
    Debug.Assert tempRef.Count = 0

    ' 4. 起始 > 结束
    Set tempRef = baseSlice.copyToNewArray(2, 1)
    Debug.Assert tempRef.Count = 0

    ' 5. 起始 = 结束 - 1
    Set tempRef = baseSlice.copyToNewArray(1, 2)
    Debug.Assert tempRef.Count = 1
    Debug.Assert tempRef.Item(0) Is c2
End Sub